package cn.ym.ymcc.service.impl;

import cn.ym.ymcc.domain.Config;
import cn.ym.ymcc.domain.Config;
import cn.ym.ymcc.mapper.ConfigMapper;
import cn.ym.ymcc.mapper.ConfigMapper;
import cn.ym.ymcc.query.ConfigQuery;
import cn.ym.ymcc.result.PageList;
import cn.ym.ymcc.service.IConfigService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 参数配置表 服务实现类
 * </p>
 *
 * @author 210513347@qq.com
 * @since 2023-05-04
 */
@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {

    @Autowired
    private ConfigMapper configMapper;

    @Override
    public PageList<Config> queryPage(ConfigQuery query) {
        //1.查询总数量 - 前端计算分页栏
        Long count = configMapper.queryCount(query);
        if(count < 1){//没有数据
            return new PageList<>();
        }
        //2.查询当前页的分页数据 - 前端展示当前页的数据
        List<Config> list = configMapper.queryData(query);
        return new PageList<>(count,list);
    }
}
